
package com.ceair.flight.refund.location.dt.enums;

import java.util.Calendar;

public enum SegrpuTimeUnit {
	
	MIN("N", Calendar.MINUTE), HOUR("H", Calendar.HOUR_OF_DAY), DAY("D", Calendar.DAY_OF_MONTH), MONTH("M", Calendar.MONTH);
	
	private final String code;
	
	private final int unit;
	
	SegrpuTimeUnit(String code, int unit) {
		this.code = code;
		this.unit = unit;
	}
	
	public String getCode() {
		return code;
	}
	
	public int getUnit() {
		return unit;
	}
	
	public static SegrpuTimeUnit getUnitByCode(String code) {
		for (SegrpuTimeUnit status : SegrpuTimeUnit.values()) {
			if (status.getCode().equals(code)) {
				return status;
			}
		}
		return null;
	}
	
}
